package com.woniu.smart.controller;

import com.woniu.smart.dto.CarDTO;
import com.woniu.smart.service.AccessService;
import com.woniu.smart.service.CarService;
import com.woniu.smart.service.VisitorService;
import com.woniu.smart.util.Result;
import com.woniu.smart.vo.CarVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：zhulongxing
 * @date ：Created in 2022/10/20 17:59
 * @description：这个板块多多少少有点问题啊
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping("accesses")
public class AccessController {
    @Autowired
    private CarService carService;
    @Autowired
    private AccessService accessService;
    @Autowired
    private VisitorService visitorService;

    @Transactional
    @PostMapping("delByIds")
    public Result delByIds(@RequestParam("visitorIds") List<Integer> visitorIds) {
        int i = carService.deleteByIds(visitorIds);
        int deleteBatch = visitorService.deleteBatch(visitorIds);
        int delete = accessService.deleteByIds(visitorIds);
        return Result.ok();
    }
    @Transactional
    @DeleteMapping("{visitorId}")
    public Result delete(@PathVariable("visitorId") Long visitorId) {
        int delete = carService.deleteByPrimaryKey(visitorId);
        int i = visitorService.deleteById(visitorId);
        int primaryKey = accessService.deleteByPrimaryKey(visitorId);
        return Result.ok();
    }
}
